home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 37 / Amiga Format CD37 (1999-02-16)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-03].iso / -screenplay- / otherstuff / swos2etw / swos2etw.c < prev    next >
C/C++ Source or Header  |  1999-01-04  |  13KB  |  689 lines

  1. /*
  2.  * SWOS2ETW 1.0, written by Gabriele Greco of Hurricane Studios
  3.  *
  4.  * This program converts SWOS team files to ETW team files.
  5.  *
  6.  * This program is Public Domain.
  7.  *
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include "swos2etw.h"
  14.  
  15. #define LNIBBLE(x) (x&0x0f)
  16. #define HNIBBLE(x) ((x>>4)&0x0f)
  17.  
  18. // SWOS stats are from 0-15, ETW ones from 0-9 (but 0-1 are reserved!)
  19.  
  20. #define ConvertHi(x) (HNIBBLE(x)/2+2)
  21. #define ConvertLo(x) (LNIBBLE(x)/2+2)
  22.  
  23. char VERSION[]="$VER: swos2etw 1.3 (29.12.98) by Gabriele Greco\n";
  24.  
  25. struct Nation
  26. {
  27.     char Name[4];
  28.     char number;
  29. };
  30.  
  31. char nation_array[50];
  32.  
  33. struct Nation nations[]=
  34. {
  35.     "ALB",29, //no!
  36.     "AUT",11,
  37.     "BEL",5,
  38.     "BUL",29,
  39.     "CRO",18,
  40.     "CYP",19, //no!
  41.     "TCH",13,
  42.     "DEN",24,
  43.     "ENG",3,
  44.     "EST",15, //no!
  45.     "FAR",3, //no!
  46.     "FIN",22,
  47.     "FRA",6,
  48.     "GER",10,
  49.     "GRE",19,
  50.     "HUN",29, //no!
  51.     "ISL",22, //no!
  52.     "ISR",19, //no!
  53.     "ITA",0,
  54.     "LAT",0, //no!
  55.     "LIT",15, //no!
  56.     "LUX",10, //no!
  57.     "MLT",0, //no!
  58.     "HOL",4,
  59.     "NIR",22, //no!
  60.     "NOR",22,
  61.     "POL",25,
  62.     "POR",8,
  63.     "ROM",20,
  64.     "RUS",15,
  65.     "SMR",15, //no!
  66.     "SCO",31,
  67.     "SLO",14,
  68.     "SWE",21,
  69.     "TUR",19, //no!
  70.     "UKR",16,
  71.     "WAL",3, //no!
  72.     "YUG",17,
  73.     "BLS",15, //no!
  74.     "SVK",16, //no!
  75.     "ESP",7,
  76.     "ARM",15, //no!
  77.     "BOS",17, //no!
  78.     "AZB",16, //no!
  79.     "GEO",15, //no!
  80.     "SWI",12,
  81.     "IRL",10,
  82.     "MAC",10, //no!
  83.     "TRK",19, //no!
  84.     "LIE",15, //no!
  85.     "MOL",16, //no!
  86.     "CRC",15, //no!
  87.     "SAL",16, //no!
  88.     "GUA",26, //no!
  89.     "HON",39, //no!
  90.     "BHM",26, //no!
  91.     "MEX",30,
  92.     "PAN",44, //no!
  93.     "USA",27,
  94.     "BAH",27, //no!
  95.     "NIC",26, //no!
  96.     "BER",26, //no!
  97.     "JAM",44,
  98.     "TRI",42, //no!
  99.     "CAN",28,
  100.     "BAR",42, //no!
  101.     "ELS",39, //no!
  102.     "SVC",39, //no!
  103.     "ARG",2,
  104.     "BOL",26, //no!
  105.     "BRA",1,
  106.     "CHL",33,
  107.     "COL",42,
  108.     "ECU",33, //no!
  109.     "PAR",39,
  110.     "SUR",33, //no!
  111.     "URU",26,
  112.     "VEN",33, //no!
  113.     "GUY",26, //no!
  114.     "PER",42, //no!
  115.     "ALG",41, //no!
  116.     "SAF",42, //no!
  117.     "BOT",35, //no!
  118.     "BFS",41, //no!
  119.     "BUR",35, //no!
  120.     "LES",32, //no!
  121.     "ZAI",37, //no!
  122.     "ZAM",37, //no!
  123.     "GHA",37, //no!
  124.     "SEN",35, //no!
  125.     "CIV",35, //no!
  126.     "TUN",41,
  127.     "MLI",37, //no!
  128.     "MDG",35, //no!
  129.     "CMR",35, //no!
  130.     "CHD",35, //no!
  131.     "UGA",37, //no!
  132.     "LIB",41, //no!
  133.     "MOZ",32, //no!
  134.     "KEN",35, //no!
  135.     "SUD",35,
  136.     "SWA",32, //no!
  137.     "ANG",35, //no!
  138.     "TOG",37, //no!
  139.     "ZIM",37, //no!
  140.     "EGY",32, //no!
  141.     "TAN",37, //no!
  142.     "NIG",37,
  143.     "ETH",35, //no!
  144.     "GAB",37, //no!
  145.     "SIE",37, //no!
  146.     "BEN",37, //no!
  147.     "CON",41, //no!
  148.     "GUI",32, //no!
  149.     "SRL",32, //no!
  150.     "MAR",32,
  151.     "GAM",37, //no!
  152.     "MLW",43, //no!
  153.     "JAP",43,
  154.     "TAI",43, //no!
  155.     "IND",43, //no!
  156.     "BAN",36, //No
  157.     "BRU",36, //No
  158.     "IRA",40, //no!
  159.     "JOR",40, //no!
  160.     "SRI",40, //no!
  161.     "SYR",40, //no!
  162.     "KOR",43, //no!
  163.     "IRN",40,
  164.     "VIE",43, //no!
  165.     "MLY",36, //No
  166.     "SAU",36,
  167.     "YEM",43, //no!
  168.     "KUW",40, //no!
  169.     "LAO",43, //no!
  170.     "NKR",40, //no!
  171.     "OMA",36, //no!
  172.     "PAK",36, //no!
  173.     "PHI",36, //no!
  174.     "CHN",40, //no!
  175.     "SGP",36, //no!
  176.     "MAU",36, //no!
  177.     "MYA",36, //no!
  178.     "PAP",36, //no!
  179.     "TAD",36, //no!
  180.     "UZB",36, //no!
  181.     "QAT",36, //no!
  182.     "UAE",37, // no!
  183.     "AUS",36, //no!
  184.     "NZL",36, //no!
  185.     "FIJ",36, //no!
  186.     "SOL",36, //no!
  187.     "CUS",36, //no!
  188. };
  189.  
  190. long costs[]=
  191. {
  192.     15,
  193.     25,
  194.     30,
  195.     40,
  196.     50,
  197.     65,
  198.     75,
  199.     85,
  200.     100,
  201.     110,
  202.     130,
  203.     160,
  204.     180,
  205.     200,
  206.     225,
  207.     250,
  208.     300,
  209.     350,
  210.     450,
  211.     500,
  212.     550,
  213.     600,
  214.     650,
  215.     700,
  216.     750,
  217.     800,
  218.     850,
  219.     950,
  220.     1000,
  221.     1100,
  222.     1300,
  223.     1500,
  224.     1600,
  225.     1800,
  226.     1900,
  227.     2000,
  228.     2250,
  229.     2750,
  230.     3000,
  231.     3500,
  232.     4500,
  233.     5000,
  234.     6000,
  235.     7000,
  236.     8000,
  237.     9000,
  238.     10000,
  239.     12000,
  240.     15000,
  241.     20000,
  242. };
  243.  
  244. #define P_VERDE0 0
  245. #define P_BIANCO 1
  246. #define P_VERDE1 2
  247. #define P_VERDE2 3
  248. #define P_NERO  4
  249. #define P_ARANCIO1 5
  250. #define P_BLU2   6
  251. #define P_ROSSO1 7
  252. #define P_BLU1 8
  253. #define P_ROSSO0 9
  254. #define P_ROSSO2 10
  255. #define P_ARANCIO0 11
  256. #define P_GIALLO 12
  257. #define P_GRIGIO1 13
  258. #define P_GRIGIO0 14
  259. #define P_BLU0 15
  260.  
  261. unsigned char color_table[]=
  262. {
  263.     P_GRIGIO0,
  264.     P_BIANCO,
  265.     P_NERO,
  266.     P_ARANCIO0,
  267.     P_ROSSO0,
  268.     P_BLU1,
  269.     P_ROSSO1,
  270.     P_BLU0,
  271.     P_VERDE0,
  272.     P_GIALLO
  273. };
  274.  
  275. char *tactics[]=
  276. {
  277.     "4-4-2",
  278.     "5-4-1",
  279.     "5-4-1", // 4-5-1 missing
  280.     "5-3-2",
  281.     "3-5-2",
  282.     "4-3-3",
  283.     "4-3-3", // 4-2-4
  284.     "3-4-3",
  285.     "5-4-1", // sweep
  286.     "5-3-2", // 5-2-3
  287.     "3-4-3", // at
  288.     "5-4-1", // def
  289.     "4-4-2",
  290.     "4-4-2",
  291.     "4-4-2",
  292.     "4-4-2",
  293.     "4-4-2",
  294.     "4-4-2",
  295.  
  296. };
  297.  
  298. struct Campionato_Disk camp=
  299. {
  300.     "Imported from SWOS",
  301.     CAMP_LEAGUE,2,3,1,0,
  302.     0
  303. };
  304.  
  305. unsigned ConvertRole(unsigned char role)
  306. {
  307.     if((role&R_A)==R_A)
  308.         return P_ATTACCO;
  309.     else if((role&R_M)==R_M)
  310.         return P_CENTRO;
  311.     else if((role&R_D)==R_D)
  312.         return P_DIFESA;
  313.     else if((role&R_LW)==R_LW)
  314.         return P_CENTRO|P_MANCINO;
  315.     else if((role&R_RW)==R_RW)
  316.         return P_CENTRO|P_DESTRO;
  317.     else if((role&R_LB)==R_LB)
  318.         return P_DIFESA|P_MANCINO;
  319.     else if((role&R_RB)==R_RB)
  320.         return P_DIFESA|P_DESTRO;
  321.     else
  322.         return 0;
  323. }
  324.  
  325. void AdjustFormation(struct Squadra_Disk *s)
  326. {
  327.     int attack,center,defence,la,lc,ld,i;
  328.     struct Giocatore_Disk temp;
  329.  
  330.     attack=s->Tattiche[0][4]-'0';
  331.     defence=s->Tattiche[0][0]-'0';
  332.     center=s->Tattiche[0][2]-'0';
  333.  
  334.     if((defence+attack+center)!=10)
  335.     {
  336.         attack=2;
  337.         defence=4;
  338.         center=4;
  339.     }
  340.  
  341.     la=9;
  342.     lc=la-attack;
  343.     ld=lc-center;
  344.  
  345.     for(i=0;i<s->NumeroGiocatori&&attack>0;i++)
  346.     {
  347.         if(s->giocatore[i].Posizioni&P_ATTACCO)
  348.         {
  349.             temp=s->giocatore[i];
  350.             s->giocatore[i]=s->giocatore[la];
  351.             s->giocatore[la]=temp;
  352.  
  353.             attack--;
  354.             la--;
  355.         }
  356.     }
  357.  
  358.     for(i=0;i<s->NumeroGiocatori&¢er>0;i++)
  359.     {
  360.         if(s->giocatore[i].Posizioni&P_CENTRO)
  361.         {
  362.             temp=s->giocatore[i];
  363.             s->giocatore[i]=s->giocatore[lc];
  364.             s->giocatore[lc]=temp;
  365.  
  366.             center--;
  367.             lc--;
  368.         }
  369.     }
  370.  
  371.     for(i=0;i<s->NumeroGiocatori&&defence>0;i++)
  372.     {
  373.         if(s->giocatore[i].Posizioni&P_DIFESA)
  374.         {
  375.             temp=s->giocatore[i];
  376.             s->giocatore[i]=s->giocatore[ld];
  377.             s->giocatore[ld]=temp;
  378.  
  379.             defence--;
  380.             ld--;
  381.         }
  382.     }
  383. }
  384.  
  385. void ConvertTeam(struct SWOS_Team *src,struct Squadra_Disk *dest)
  386. {
  387.     unsigned char role;
  388.     char *tmp_c;
  389.     int i,j;
  390.  
  391.     memset(dest,0,sizeof(struct Squadra_Disk));
  392.     memset(nation_array,0,sizeof(nation_array));
  393.  
  394.     strcpy(dest->nome,src->TeamName);
  395.     strcpy(dest->allenatore,src->CoachName);
  396.     
  397.     if(src->Division)
  398.         dest->Flags=1<<(src->Division-1);
  399.     else
  400.         dest->Flags=0;
  401.  
  402.     for(i=0;i<3;i++)
  403.         strcpy(dest->Tattiche[i],tactics[src->Formation]);
  404.  
  405.     for(i=0;i<2;i++)
  406.     {
  407.         dest->maglie[i].Colore1=color_table[src->Shirts[i].Pantaloni];
  408.  
  409.         switch(src->Shirts[i].Type)
  410.         {
  411.             case 1:
  412.                 dest->maglie[i].Tipo=2;
  413.                 dest->maglie[i].Colore2=color_table[src->Shirts[i].Shirt1];
  414.                 dest->maglie[i].Colore0=color_table[src->Shirts[i].Shirt2];
  415.                 break;
  416.             case 2:
  417.                 dest->maglie[i].Tipo=1;
  418.                 dest->maglie[i].Colore0=color_table[src->Shirts[i].Shirt1];
  419.                 dest->maglie[i].Colore2=color_table[src->Shirts[i].Shirt2];
  420.                 break;
  421.             default:
  422.                 dest->maglie[i].Tipo=0;
  423.                 dest->maglie[i].Colore0=color_table[src->Shirts[i].Shirt1];
  424.         }
  425.     }
  426.  
  427.     for(i=0;i<16;i++)
  428.     {
  429.         char *tmp_n=src->Players[i].Name;
  430.         j=0;
  431.  
  432.         while(tmp_n[j]>' ')
  433.             j++;
  434.  
  435.         if(tmp_n[j]==0)
  436.         {
  437. // j==0 -> empty slot
  438.             if(j==0)
  439.                 continue;
  440.  
  441.             tmp_c=tmp_n;
  442.             tmp_n=NULL;
  443.         }
  444.         else
  445.         {
  446.             tmp_c=(&tmp_n[j])+1;
  447.             tmp_n[j]=0;
  448.         }
  449.  
  450.         nation_array[nations[src->Players[i].Nation].number]++;
  451.  
  452.         if(!(role=ConvertRole(src->Players[i].Role)))
  453.         {
  454. // Player i is a gk...
  455.             if(dest->NumeroPortieri>2)
  456.             {
  457.                 printf("Too many keepers in %s, ETW supports up to 3 GK!\n",src->TeamName);
  458.                 exit(20);
  459.             }
  460.  
  461.             if(tmp_n)
  462.                 strcpy(dest->portiere[dest->NumeroPortieri].Nome,tmp_n);
  463.             else
  464.                 *dest->portiere[dest->NumeroPortieri].Nome=0;
  465.  
  466.             strcpy(dest->portiere[dest->NumeroPortieri].Cognome,tmp_c);
  467.  
  468.             dest->portiere[dest->NumeroPortieri].Nazionalita=nations[src->Players[i].Nation].number;
  469.             dest->portiere[dest->NumeroPortieri].Numero=src->Players[i].Number;
  470.             dest->portiere[dest->NumeroPortieri].valore=costs[src->Players[i].value];
  471.  
  472.             if(src->Players[i].value>46)
  473.             {
  474.                 dest->portiere[dest->NumeroPortieri].Velocita=9;
  475.                 dest->portiere[dest->NumeroPortieri].Parata=9;
  476.                 dest->portiere[dest->NumeroPortieri].Attenzione=9;
  477.             }
  478.             else if(src->Players[i].value>40)
  479.             {
  480.                 dest->portiere[dest->NumeroPortieri].Velocita=8;
  481.                 dest->portiere[dest->NumeroPortieri].Parata=8;
  482.                 dest->portiere[dest->NumeroPortieri].Attenzione=9;
  483.             }
  484.             else if(src->Players[i].value>35)
  485.             {
  486.                 dest->portiere[dest->NumeroPortieri].Velocita=7;
  487.                 dest->portiere[dest->NumeroPortieri].Parata=8;
  488.                 dest->portiere[dest->NumeroPortieri].Attenzione=8;
  489.             }
  490.             else if(src->Players[i].value>30)
  491.             {
  492.                 dest->portiere[dest->NumeroPortieri].Velocita=7;
  493.                 dest->portiere[dest->NumeroPortieri].Parata=7;
  494.                 dest->portiere[dest->NumeroPortieri].Attenzione=8;
  495.  
  496.             }
  497.             else if(src->Players[i].value>25)
  498.             {
  499.                 dest->portiere[dest->NumeroPortieri].Velocita=6;
  500.                 dest->portiere[dest->NumeroPortieri].Parata=7;
  501.                 dest->portiere[dest->NumeroPortieri].Attenzione=8;
  502.             }
  503.             else if(src->Players[i].value>20)
  504.             {
  505.                 dest->portiere[dest->NumeroPortieri].Velocita=6;
  506.                 dest->portiere[dest->NumeroPortieri].Parata=7;
  507.                 dest->portiere[dest->NumeroPortieri].Attenzione=7;
  508.             }
  509.             else if(src->Players[i].value>18)
  510.             {
  511.                 dest->portiere[dest->NumeroPortieri].Velocita=6;
  512.                 dest->portiere[dest->NumeroPortieri].Parata=6;
  513.                 dest->portiere[dest->NumeroPortieri].Attenzione=6;
  514.             }
  515.             else if(src->Players[i].value>14)
  516.             {
  517.                 dest->portiere[dest->NumeroPortieri].Velocita=5;
  518.                 dest->portiere[dest->NumeroPortieri].Parata=5;
  519.                 dest->portiere[dest->NumeroPortieri].Attenzione=5;
  520.             }
  521.             else if(src->Players[i].value>10)
  522.             {
  523.                 dest->portiere[dest->NumeroPortieri].Velocita=4;
  524.                 dest->portiere[dest->NumeroPortieri].Parata=5;
  525.                 dest->portiere[dest->NumeroPortieri].Attenzione=4;
  526.             }
  527.             else if(src->Players[i].value>8)
  528.             {
  529.                 dest->portiere[dest->NumeroPortieri].Velocita=4;
  530.                 dest->portiere[dest->NumeroPortieri].Parata=4;
  531.                 dest->portiere[dest->NumeroPortieri].Attenzione=4;
  532.  
  533.             }
  534.             else if(src->Players[i].value>4)
  535.             {
  536.                 dest->portiere[dest->NumeroPortieri].Velocita=3;
  537.                 dest->portiere[dest->NumeroPortieri].Parata=4;
  538.                 dest->portiere[dest->NumeroPortieri].Attenzione=3;
  539.             }
  540.             else
  541.             {
  542.                 dest->portiere[dest->NumeroPortieri].Velocita=2;
  543.                 dest->portiere[dest->NumeroPortieri].Parata=2;
  544.                 dest->portiere[dest->NumeroPortieri].Attenzione=2;
  545.             }
  546.  
  547.             dest->NumeroPortieri++;
  548.         }
  549.         else
  550.         {
  551.             if(tmp_n)
  552.                 strcpy(dest->giocatore[dest->NumeroGiocatori].Nome,tmp_n);
  553.             else
  554.                 *dest->giocatore[dest->NumeroGiocatori].Nome=0;
  555.  
  556.             strcpy(dest->giocatore[dest->NumeroGiocatori].Cognome,tmp_c);
  557.  
  558.             dest->giocatore[dest->NumeroGiocatori].Nazionalita=nations[src->Players[i].Nation].number;
  559.             dest->giocatore[dest->NumeroGiocatori].Numero=src->Players[i].Number;
  560.             dest->giocatore[dest->NumeroGiocatori].valore=costs[src->Players[i].value];
  561.  
  562.             dest->giocatore[dest->NumeroGiocatori].Posizioni=role | ( (src->Players[i].Role&GIOCATORE_PELLE_NERA) ? P_PELLE_NERA : 0L) ;
  563.  
  564.             dest->giocatore[dest->NumeroGiocatori].Velocita=ConvertHi(src->Players[i].SpeedFitness);
  565.             dest->giocatore[dest->NumeroGiocatori].Contrasto=ConvertHi(src->Players[i].TackleControl);
  566.             dest->giocatore[dest->NumeroGiocatori].Tiro=ConvertHi(src->Players[i].ShotHeading);
  567.             dest->giocatore[dest->NumeroGiocatori].Durata=ConvertLo(src->Players[i].SpeedFitness);
  568.             dest->giocatore[dest->NumeroGiocatori].Resistenza=ConvertLo(src->Players[i].ShotHeading); // Resistenza is Heading!
  569.             dest->giocatore[dest->NumeroGiocatori].Creativita=ConvertLo(src->Players[i].EmptyPassing);
  570.             dest->giocatore[dest->NumeroGiocatori].Tecnica=ConvertLo(src->Players[i].TackleControl);
  571.             dest->giocatore[dest->NumeroGiocatori].Prontezza=ConvertHi(src->Players[i].SpeedFitness);
  572.  
  573. // SWOS doesn't support player age...
  574.  
  575.             dest->giocatore[dest->NumeroGiocatori].Eta=19+(rand()%13);
  576.  
  577.             dest->NumeroGiocatori++;
  578.         }
  579.     }
  580.  
  581. // Trovo la nazionalita'...
  582.  
  583.         role=99;
  584.     j=0;
  585.  
  586.     for(i=0;i<sizeof(nation_array);i++)
  587.     {
  588.         if(nation_array[i]>j)
  589.         {
  590.             j=nation_array[i];
  591.             role=i;
  592.                 }
  593.     }
  594.  
  595.     if(role==99)
  596.         role=0;
  597.  
  598.     dest->Nazione=role;
  599.  
  600.     AdjustFormation(dest);
  601. }
  602.  
  603. int main(int argc, char *argv[])
  604. {
  605.     FILE *f,*out;
  606.     struct SWOS_Team swos_team;
  607.     struct Squadra_Disk etw_team;
  608.  
  609.     if(argc<3||argc>4)
  610.     {
  611.         printf("Usage: %s SWOS-TeamFile ETW-TeamFile [League Name]\n",argv[0]);
  612.         exit(0);
  613.     }
  614.  
  615.     if(argc==4)
  616.         strcpy(camp.Nome,argv[3]);
  617.  
  618.     if(f=fopen(argv[1],"rb"))
  619.     {
  620.         short team_number;
  621.         int i,k,allow_skip=0;
  622.  
  623.         fread(&team_number,sizeof(short),1,f);
  624.  
  625.                 if(team_number==0x524e)
  626.         {
  627.             printf("This file is packed with RNC, you have to depack it!\n");
  628.             exit(0);
  629.         }
  630.         printf("%d teams found in <%s>...\n",team_number,argv[1]);
  631.  
  632.         if(!(out=fopen(argv[2],"wb")))
  633.         {
  634.             printf("Unable to create the output file <%s>!\n",argv[2]);
  635.             exit(20);
  636.         }
  637.  
  638.         if(team_number<1)
  639.         {
  640.             printf("Incorrect team number!\n");
  641.             exit(20);
  642.         }
  643.  
  644.         if(team_number>64)
  645.         {
  646.             printf("WARNING, more than 64 teams (%d), skipping the ones with div = 0\n",team_number);
  647.             allow_skip=1;
  648.         }
  649.  
  650.         camp.NumeroSquadre=team_number-1;
  651.  
  652.         fwrite(&camp,sizeof(struct Campionato_Disk),1,out);
  653.  
  654.         for(i=0,k=0;i<team_number && k<64;i++)
  655.         {
  656.             fread(&swos_team,sizeof(struct SWOS_Team),1,f);
  657.  
  658.             if(allow_skip && swos_team.Division>1 )
  659.                 continue;
  660.  
  661.             k++;
  662.             ConvertTeam(&swos_team,&etw_team);
  663.             fwrite(&etw_team,sizeof(struct Squadra_Disk),1,out);
  664.         }
  665.  
  666.         if(allow_skip)
  667.         {
  668.             if(k==64)
  669.                 printf("WARNING, could not reach the end of the file (too many teams!)\n");
  670.  
  671.             printf("%d teams skipped!\n",team_number-k);
  672.  
  673.             camp.NumeroSquadre=k-1;
  674.             fseek(out,0,SEEK_SET);
  675.             fwrite(&camp,sizeof(struct Campionato_Disk),1,out);
  676.         }
  677.  
  678.         printf("%d teams written to <%s>\n",k,argv[2]);
  679.  
  680.         fclose(out);
  681.         fclose(f);
  682.     }
  683.     else
  684.     {
  685.         printf("Unable to open source file!\n");
  686.         exit(20);
  687.     }
  688. }
  689.